{extend name="../../admin/view/main"}

{block name='content'}
<form action="{:sysuri()}" class="layui-card layui-form" data-auto="true" method="post">
    <div class="layui-card-body">

        <!--{notempty name='marks'}-->
        <div class="layui-form-item label-required-prev">
            <span class="help-label"><b>文章标签</b>News Mark</span>
            <div class="layui-textarea help-checks">
                {foreach $marks as $tag}{if isset($vo.mark) && is_array($vo.mark) && in_array($tag.name, $vo.mark)}
                <label class="think-checkbox notselect"><input checked lay-ignore name="mark[]" type="checkbox" value="{$tag.name}"> {$tag.name}</label>
                {else}
                <label class="think-checkbox notselect"><input lay-ignore name="mark[]" type="checkbox" value="{$tag.name}"> {$tag.name}</label>
                {/if}{/foreach}
            </div>
        </div>
        <!--{/notempty}-->

        <div class="layui-form-item label-required-prev">
            <span class="help-label"><b>文章封面</b>News Conver</span>
            <div class="relative block label-required-null">
                <input class="layui-input think-bg-gray" name="cover" placeholder="请上传文章封面" readonly required value='{$vo.cover|default=""}'>
                <a class="layui-icon layui-icon-upload input-right-icon" data-file data-field="cover" data-type="gif,png,jpg,jpeg"></a>
            </div>
        </div>

        <label class="layui-form-item relative block">
            <span class="help-label"><b>文章标题</b>News Title</span>
            <input class="layui-input" name="name" placeholder="请输入文章标题" required value='{$vo.name|default=""}'>
        </label>

        <div class="layui-form-item label-required-prev">
            <span class="help-label"><b>文章内容</b>News Content</span>
            <label class="relative block">
                <textarea class="layui-hide" name="content" placeholder="请输入文章内容">{$vo.content|default=''}</textarea>
            </label>
        </div>

        <div class="hr-line-dashed"></div>
        {notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}

        <div class="layui-form-item text-center">
            <button class="layui-btn" type="submit">保存数据</button>
            <button class="layui-btn layui-btn-danger" data-history-back data-confirm="确定要取消编辑吗？" type='button'>取消编辑</button>
        </div>
    </div>

</form>

<script>
    $('input[name="cover"]').uploadOneImage();
    // require(['ckeditor'], function () {
    // window.createEditor('[name=content]', {height: 350});
    // });

    require(['ckeditor5'], function (ClassicEditor) {
        ClassicEditor.create(document.querySelector('[name=content]'), {
            licenseKey: '',
            indentBlock: {offset: 1, unit: 'em'},
            fontSize: {options: [9, 11, 12, 'default', 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]},
            fontFamily: {
                options: [
                    'default',
                    '微软雅黑, Microsoft YaHei',
                    '新宋体, NSimSun',
                    '宋体, SimSun',
                    '仿宋, FangSong',
                    '楷体, KaiTi',
                    '黑体, SimHei',
                    'Arial, Helvetica, sans-serif',
                    'Tahoma, Geneva, sans-serif',
                    'Verdana, Geneva, sans-serif',
                    'Courier New, Courier, monospace',
                ]
            },
        }).then(function (editor) {
            window.editor = editor;
            // editor.model.sourceElement.style
            editor.$element = $(editor.sourceElement);
            editor.$element.data('editor', editor).triggerHandler('init', editor);
            editor.model.document.on("change:data", function () {
                editor.$element.val(editor.getData())
            });
        }).catch(function (error) {
            console.error('Oops, something went wrong!');
            console.error('Please, report the following error on https://github.com/ckeditor/ckeditor5/issues with the build id and the error stack trace:');
            console.warn('Build id: yw6zhbblcdbg-b5dhd7ee5sv3');
            console.error(error);
        });
    })
</script>
{/block}
